package com.chatviewer.blog.controller;


import com.chatviewer.blog.base.Result;
import com.chatviewer.blog.base.ResultUtils;
import com.gearwenxin.client.PromptBotClient;
import com.gearwenxin.entity.chatmodel.ChatPromptRequest;
import com.gearwenxin.entity.response.PromptResponse;
import com.gearwenxin.entity.response.PromptResult;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Ge Mingjia
 * @date 2023/7/29
 */
@RestController
@RequestMapping("/propt")
public class PromptController {

    @Resource
    private PromptBotClient promptClient;

    // 模板对话
    @RequestMapping
    public Result<Object> chatSingle() {

        Map<String, String> map = new HashMap<>();
        map.put("3", "“桂林山水甲天下。”。");
        map.put("5", "201");
        ChatPromptRequest promptRequest = new ChatPromptRequest();
        promptRequest.setId(9697);
        promptRequest.setParamMap(map);
        PromptResponse promptResponse = promptClient.chatPrompt(promptRequest).block();
        //promptResponse.getResult()
        PromptResult result = promptResponse.getResult();
        System.out.println(result);
        return Result.success(result.getContent());
    }

}
